﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LevelEditor.Forms;

namespace LevelEditor.View
{
    public class DoUndoLayerVisible : DoUndoNothing
    {
        #region Fields

        int LayerIndex;

        bool DoVisible;

        bool UndoVisible;

        #endregion

        #region Constructors

        public DoUndoLayerVisible(MainForm form, int layerIndex, bool visible):base(form)
        {
            LayerIndex = layerIndex;
            UndoVisible = form.Level.Layers[LayerIndex].Visible;
            DoVisible = visible;
        }

        #endregion

        #region Methods

        public override bool Do()
        {
            MainForm.Level.Layers[LayerIndex].Visible = DoVisible;
            MainForm.RefreshControlData();
            return base.Do();
        }

        public override void Undo()
        {
            MainForm.Level.Layers[LayerIndex].Visible = UndoVisible;
            MainForm.RefreshControlData();
        }

        public override string ToString()
        {
            return "Layer " + LayerIndex.ToString() + " visible: " + DoVisible.ToString();
        }

        #endregion
    }
}
